const Queries = {
  isVoid(editor, node) {
    const { schema } = editor;
    return schema.isVoid(node);
  },
  isAtomic(editor, node) {
    const { schema } = editor;
    return schema.isAtomic(node);
  },
  isInline(editor, node) {
    const { schema } = editor;
    return schema.isInline(node);
  },
  getNotAtomicNode(editor, node) {
    if (editor.isAtomic(node)) {
      const { document } = editor.value;
      const parent = document.getParent(node.key);
      return editor.getNotAtomicNode(parent);
    }
    return node;
  },
  getNotVoidNode(editor, node) {
    if (editor.isVoid(node)) {
      const { document } = editor.value;
      const parent = document.getParent(node.key);
      return editor.getNotVoidNode(parent);
    }
    return node;
  },
  validateChild(editor, parent, node) {
    const { schema } = editor;
    return schema.validateNodes(parent, node);
  },
  isSelected(editor, node) {
    const { value } = editor;
    return value.isSelected(node);
  },
  canUndo(editor) {
    const { value } = editor;
    return value.undoStack.size > 0;
  },
  canRedo(editor) {
    const { value } = editor;
    return value.redoStack.size > 0;
  },
  getAllFormNodes(editor) {
    return editor.value.getAllFormNodes();
  }
};

export default Queries;
